<!--#include file="admin/Includes/constants.asp"-->
<!--#include file="admin/Includes/validate.asp"-->
<!--#include file="admin/Includes/Send_Mail.asp"-->
<!--#include file="admin/Includes/validation.asp"-->

<%
Dim origmail_source, origmail_from,  origmail_subject, origmail_body, receiver, Icon
Dim reqtype, reqsubject
Dim hideform, strMes, Action
Dim referer, ArticleID, DocType, CatID, ImageID, ImageName
Dim mes
Dim ccname1, ccname2, ccname1_em, ccname2_em, scc
Dim rqMsgText, senderemail, addMsg

ccname1 = request("ccname1")
ccname2 = request("ccname2")
ccname1_em = request("ccname1_em")
ccname2_em = request("ccname2_em")
rqMsgText = request("rqMsgText")


reqtype=request("r")
reqsubject = request("s")
Action = request("act")
ImageID= request("iid")
ImageName= request("in")

'link send to friend
referer = request("r")
if referer = "" then 
	referer = Request.ServerVariables("HTTP_REFERER")
	If instrRev(referer, "ckid") > 0 Then
	referer = left(referer, instrRev(referer, "ckid")-2)
	End If
	If instr(referer, "detail_print") > 0 Then
	referer = replace(referer, "detail_print","detail")
	End If
End If

If request.Form("dt") <> "" Then
	DocType=request.Form("dt")
Else
	DocType=request.QueryString("dt")
End If

If request.Form("aid") <> "" Then
	ArticleID=request.Form("aid")
Else
	ArticleID=request.QueryString("aid")
End If
If request.Form("mcid") <> "" Then
	CatID = request.Form("mcid")
Else
	CatID=request.QueryString("mcid")
End If

If Action <> "" Then	
	dim namefrom, nameto

	namefrom = getData("rqNameFrom")
	nameto = getData("rqNameTo")
	origmail_source  = Domain_Name
	origmail_from = Replace(request.form("rqfrom_em"),"'","''")
	senderemail = origmail_from 
	receiver = request.form("rqTo_em")
	
	if isEmail(origmail_from) and isEmail(receiver) then			
		dim psemail 
		psemail = getpsemail()
	
		'Update Article Stats
		If DocType="1" Then
			If ArticleID="0" Then 'handle top 20 articles
				ArticleID="200" &  CatID 
			ElseIf ArticleID="" Then
				ArticleID="0" 'Homepage
			End If
		End If
		
		origmail_subject = namefrom &  " (" & origmail_from & ") moi ban xem thoitrang.com"

		if rqMsgText <> "" then
			addMsg = "Ngoài ra "&namefrom&" cũng nhắn tin cho bạn<br>"&_
					 "--------------------------------------------------<br>" &_
					 rqMsgText & "<br>" &_
					 "--------------------------------------------------<br><br>" 
		end if
		
		sub sendecard (ToName1, ToEmail1)
			If DocType="3" Then 'wallpaper			, or 4 because wrong pass parametter
				ArticleID=ImageID
				origmail_body = ToName1 & " mến, <br><br>" &_	
							namefrom &  " đã gửi cho bạn một hình nền (wallpaper) thời trang. Để tải hình, hãy bấm vào 1 trong 2 đường link dưới đây với độ phân giải bạn muốn.<br><br>" &_
							"<a href='http://" & request.ServerVariables("HTTP_HOST") & "/download.asp?iid=" &ImageID& "&is=800&in=" & ImageName&"' target='_new'>"  &ImageName &"</a> (800x600)<br>" &_	
							"<a href='http://" & request.ServerVariables("HTTP_HOST") & "/download.asp?iid=" &ImageID& "&is=1024&in=" & ImageName&"' target='_new'>"  &ImageName &"</a> (1024x768)<br><br>" &_	
							"Tiện thể, thân mời bạn đến <a href='http://www.thoitrang.com' target='_new'>thoitrang.com</a> để tải thêm nhiều hình nền khác, chiêm ngưỡng những bộ sưu tập mới nhất, học hỏi những bí quyết làm đẹp hay nhất và còn nhiều thứ khác nữa... .<br><br>." &_	
							addMsg &_							
							"Thân ái,<br><br>" &_
							"ThoiTrang.com<br><br>" & psemail
			Else
				origmail_body = ToName1 & " mến, <br><br>" &_	
							namefrom &  " mời bạn đến <a href='http://www.thoitrang.com' target='_new'>thoitrang.com</a> để xem một trang thời trang hay. Bạn hãy bấm vào đường link dưới đây để xem.<br><br>" &_
							"<a href='"&referer&"' target='_new'>"  &referer &"</a><br><br>" &_	
							addMsg &_
							"Thân ái,<br><br>" &_
							"ThoiTrang.com<br><br>" & psemail
			End If
		
			origmail_body = StripHardBreaks(origmail_body)
			call sentMail(strSMTP, origmail_from, namefrom, ToEmail1, origmail_subject, origmail_body)
		end sub		
		
		'main address
		sendecard nameto, receiver
		
		'cc 1
		if ccname1 <> "" and ccname1_em <> "" then 	sendecard ccname1, ccname1_em			
		'cc 2
		if ccname2 <> "" and ccname2_em <> "" then 	sendecard ccname2, ccname2_em		
		
		
		'a copy to admin
		origmail_body = "sender: " & namefrom & "<br>" &_
						"sender's email: " & origmail_from & "<br>" &_
						"recepient: " & nameto & "<br>" &_
						"recepient's email: " & receiver & "<br>" &_
						"link: " & referer
						
		origmail_subject = "New email-a-friend from thoitrang.com"
		origmail_from = "admin@thoitrang.com"		
		
		'call sentMail(strSMTP, origmail_from, namefrom, origmail_to, origmail_subject, origmail_body) 
		Icon = "<img src='hinh-thoi-trang/ico_alert.gif' alt='' width='20' height='20' border='0'>"
		strMes = "Cảm ơn <strong>" & namefrom & "</strong>! Thư của bạn đã được gởi đi."		
		hideform = true		
		
		
		' save email of all user
		strSQL = "{CALL a_email_friends_add (N'" & namefrom & "',N'" & senderemail & "',N'" & nameto & "',N'" & receiver & "',N'" & ccname1 & "',N'" & ccname1_em & "',N'" & ccname2 & "',N'" & ccname2_em & "')}"	
		exec(strsql)		
				
		strSQL = "{CALL a_emailfriend_upd ("& DocType &","& ArticleID &")}"	
		exec(strsql)
		CloseCon
	else
		
		Icon = "<img src='hinh-thoi-trang/ico_alert.gif' alt='' width='20' height='20' border='0'>"
		strMes = "Xin vui lòng nhập lại email."			
	end if
End If	

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<Meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>Thoitrang.com-goi trang cho ban</title>
	<Meta name="keywords" content="thoi trang, thoitrang, thoi trang tre, thoi trang viet nam"> 
	<Meta name="description" content="Tap chi truc tuyen thoi trang viet nam thoitrang.com">
	<Meta http-equiv=" content-language" content ="vi">
	<Meta name="Robots" content="noindex,nofollow">
	<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"> 
	<link rel="icon" href="favicon.ico" type="image/x-icon"> 
	<link rel="STYLESHEET" type="text/css" href="system/styles.css">
	<script language="javascript" src="admin/javascripts/validateVN.js"></script>
	<script src="admin/javascripts/vietUni.js" type="text/javascript"></script>
	<script language="javascript">setTypingMode(2)</script>
	<script language="javascript">
	function validate(frm){
			if (isValid(frm) == false) return false;
			if ( (frm.ccname1.value != "" && frm.ccname1_em.value  == "" ) || (frm.ccname1.value == "" && frm.ccname1_em.value  != "" ) ) { alert("Ban phải nhập đầy đủ tên và email người nhận");return false};
			if ( (frm.ccname2.value != "" && frm.ccname2_em.value  == "" ) || (frm.ccname2.value == "" && frm.ccname2_em.value  != "" ) ) { alert("Ban phải nhập đầy đủ tên và email người nhận");return false};		
			return true;
		}
	</script>	
</head>
<body <%if hideform = false then %>onLoad="document.frm.rqfrom_em.focus()" <%end if%> >
<div id="container">
<div id="bt2"><img src="hinh-thoi-trang/bg_top.gif" width="1049" height="20"></div>
<div id="tp">
<table border="0" cellpadding="0" cellspacing="0" width="990" align="center">	
	<!--top-->
	<!--#include file="system/top.asp" -->
	<!--/top-->
	<tr bgcolor="#6b5a60">
		<td width="160" style="height:1px;"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td>
		<td width="522" valign="top" rowspan="2">		
		<!--body content-->		
			<!--cover-->		
		<table border="0" cellpadding="0" cellspacing="1" width="100%" bgcolor="#B6A8AD">			
			<tr><td colspan="3" style="padding-left:12px;"><img src="hinh-thoi-trang/gui-ban-hp.gif" width="400" height="40"></td></tr>
			<tr>
				<!--col left-->		
				<td valign="top" height=680>
					<table cellpadding="0" cellspacing="0" border="0" bgcolor="#FFFFFF" width=100%%>
						<tr>
							<td style="padding-left:9px;padding-right:11px;" valign=top>
								<table cellpadding="3" cellspacing="0" border="0">								
								<% If strMes <> "" Then%>
									<tr><td colspan="3"><img src="hinh-thoi-trang/de_clear.gif" width="1" height="10" border="0"></td></tr>	
									<tr><td colspan="3" class="text"><P class="paging"><%=strMes%></P></td></tr>
								<%	End If%>
								<%If hideform = False Then%>								
								<form name ="frm" action="emailFriend.asp?ckid=<%=ckid%>" method="post" onSubmit="return  validate(this)">								
								<input type="hidden" name="r" value="<%=referer%>">		
								<input type="hidden" name="aid" value="<%=ArticleID%>">				
								<input type="hidden" name="dt" value="<%=DocType%>">			
								<input type="hidden" name="mcid" value="<%=CatID%>">		
								<input type="hidden" name="iid" value="<%=ImageID%>">		
								<input type="hidden" name="in" value="<%=ImageName%>">								
								<tr>
									<td colspan="3"><img src="de_clear" width="1" height="10" border="0"></td>
								</tr>	
								<tr>
								  <td nowrap class="paging">&nbsp;</td>
								  <td class="paging"><input type="radio" name="optInput" value="0" onFocus="setTypingMode(0)" />Off
  <input type="radio" name="optInput" value="1" onFocus="setTypingMode(1)" />Telex
  <input type="radio" name="optInput" value="2" onFocus="setTypingMode(2)" checked="checked" />VNI</td>
								  <td class="paging" style="color:#999999">&nbsp;</td>
								  </tr>
								<tr>									
									<td class="paging"><b>Tên người gởi</b> - <b>E-mail người gởi</b>:&nbsp;</td>
									<td style="padding-left:8px;" nowrap colspan=2><input type="text" name="rqNameFrom" value="<%=iv_Fullname%>" onKeyUp="initTyper(this)" id="Tên người gởi" size="30"  style="Width:110px;" class="txtInput" > - <input type="text" name="rqfrom_em"  <%if origmail_from <> "" then%> value="<%=origmail_from%>" <%else%> value="<%= iv_Retemail %>" <%end if%> id="E-mail người gởi" size="30"  style="Width:220px;" class="txtInput"></td>
								</tr>
								<tr><td colspan="3"><img src="hinh-thoi-trang/de_clear.gif" width="1" height="10" border="0"></td></tr>										
								<tr>									
									<td class="paging"><b>Tên người nhận</b> - <b>E-mail người nhận</b>:&nbsp;</td>
									<td style="padding-left:8px;" colspan=2><input type="text" onKeyUp="initTyper(this)" name="rqNameTo" value="<%=nameto%>" id="Tên người nhận" size="30"  style="Width:110px;" class="txtInput"> - <input type="text" name="rqTo_em" value="<%=receiver%>" id="Email người nhận" style="Width:220px;" class="txtInput"></td>
								</tr>							
								<tr>									
									<td class="paging"><b>Tên người nhận 1</b> - <b>E-mail người nhận 1</b>:&nbsp;</td>
									<td style="padding-left:8px;" colspan=2><input type="text" onKeyUp="initTyper(this)" name="ccname1" value="<%=nameto%>" id="Tên người nhận" size="30"  style="Width:110px;" class="txtInput"> - <input type="text" name="ccname1_em" value="<%=receiver%>" id="Email người nhận" style="Width:220px;" class="txtInput"></td>
								</tr>							
								<tr>									
									<td class="paging"><b>Tên người nhận 2</b> - <b>E-mail người nhận 2</b>:&nbsp;</td>
									<td style="padding-left:8px;" colspan=2><input type="text" onKeyUp="initTyper(this)" name="ccname2" value="<%=nameto%>" id="Tên người nhận" size="30"  style="Width:110px;" class="txtInput"> - <input type="text" name="ccname2_em" value="<%=receiver%>" id="Email người nhận" style="Width:220px;" class="txtInput"></td>
								</tr>					
								<tr>									
									<td valign="top" class="paging"><b>Nội dung</b>:&nbsp;&nbsp;</td>
									<td style="padding-left:8px;" colspan="2"><textarea cols="50" rows="9" name="rqMsgText" onKeyUp="initTyper(this)" id="Nội dung" style="Width:355px;" class="txtInput"></textarea></td>
								</tr>																										
								<tr>
									<td valign="top" class="paging">Trang gởi:&nbsp;&nbsp;</td>
									<td class="paging" colspan="2" style="padding-left:8px;"><%=referer%></td>
								</tr>	
								<tr><td colspan="3"><img src="hinh-thoi-trang/de_clear.gif" width="1" height="1" border="0"></td></tr>																							
								<tr bgcolor="#B6A8AD"><td colspan="3"  style="padding:0px;><img src="hinh-thoi-trang/de_clear.gif" width="1" height="1" border="0"></td></tr>																							
								<tr><td colspan="3"><img src="hinh-thoi-trang/de_clear.gif" width="1" height="1" border="0"></td></tr>																							
								<tr>
									<td align="right" colspan="2"><input type="submit" name="act" value="GỞI EMAIL" class="btnGo"></td>
									<td>&nbsp;</td>
								</tr>			
								</form>								
								<%else%>
								<tr><td align="right" colspan="3"><br><br>
									<a href="<%=referer%>"><img src="hinh-thoi-trang/btn_continue.gif" border="0"></a>
								</td></tr>
								<%end if%>	
								<tr><td colspan="3"><img src="hinh-thoi-trang/de_clear.gif" width="1" height="1" border="0"></td></tr>															
							</table>										
							</td>
						</tr>
					</table>						 
				</td>
				<!--/col left-->							
			</tr>
		</table>
			<!--/text-->		
		<!--/body content-->
		</td>
		<td width="308" style="width:0px;"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td>
	</tr>
	<!--main body-->
	<tr bgcolor="#ffffff">
		<td bgcolor="#000000" width="160" valign="top">
		<!--#include file="system/left.asp" -->
		</td>
		<!--missing 1 TD because of Rowspan-->		
		<td bgcolor="#614B00" width="308" valign="top">
			<table border="0" cellpadding="0" cellspacing="0" width="308" align="right">
				<tr bgcolor="#000000"><td colspan="2"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td></tr>
				<form action="search.asp?ckid=<%=ckid%>" method="post">
				<tr bgcolor="#8D0045">
					<td width="154" valign="top" height="33" ><input type="text" name="search" value="Tìm kiếm" size="22" class="txtSearch"></td>
					<td width="154" valign="top" style="padding-top:7px;padding-left:3px;"><input type="submit" name="go" value="TÌM" class="btnGo"></td>
				</tr>
				</form>
				<tr bgcolor="#000000"><td colspan="2"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td></tr>
				<!--Ads Starts-->
				<tr><td align="center" colspan="2"><img src="hinh-quang-cao/neimanmarcus350x250.jpg" alt="" width="300" height="250" border="0"></td></tr>
				<!--Ads Ends-->
			</table>
		</td>
	</tr>
	<!--/main body-->
	<!--#include file="system/bottom.asp" -->
</table>
</div>
<div id="bt2"><img src="hinh-thoi-trang/bg_bottom.gif" width="1049" height="20"></div>
</div>
</body>
</html>
